package com.ruoyi.patrol.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.patrol.domain.PtWorkPatrol;
import com.ruoyi.patrol.domain.dto.PtLocusDTO;
import com.ruoyi.patrol.service.IPtWorkLocusService;
import com.ruoyi.patrol.service.IPtWorkPatrolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 巡检轨迹Controller
 *
 * @author linan
 * @date 2024-02-03
 */
@RestController
@RequestMapping("/work/locus")
public class PtWorkLocusController extends BaseController
{
    @Autowired
    private IPtWorkLocusService ptWorkLocusService;

    /**
     * 查询巡检轨迹信息列表
     */
    @PreAuthorize("@ss.hasPermi('work:locus:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtLocusDTO locusDTO)
    {
//        startPage();
        clearPage();
        List<Map<String, Object>> list = ptWorkLocusService.selectPtWorkLocusList(locusDTO);
        return getDataTable(list);
    }

    /**
     * 新增巡检轨迹信息
     */
    @PreAuthorize("@ss.hasPermi('work:locus:add')")
    @Log(title = "巡检轨迹信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Map<String, Object> param)
    {
        return toAjax(ptWorkLocusService.insertPtWorkLocus(param));
    }

    /**
     * 删除巡检轨迹信息
     */
    @PreAuthorize("@ss.hasPermi('work:locus:remove')")
    @Log(title = "巡检轨迹信息", businessType = BusinessType.DELETE)
	@DeleteMapping
    public AjaxResult remove(PtLocusDTO locusDTO)
    {
        return toAjax(ptWorkLocusService.deletePtWorkLocus(locusDTO));
    }
}
